$(function() {
    $(".nav>li").mouseover(function() {
        $(this).children(".dropdown-layer").show();
    });
    $(".nav>li").mouseout(function() {
        $(this).children(".dropdown-layer").hide();
    });
    $(".close-btn").click(function() {
        $(this).hide().siblings("img").hide();
    });
});

document.cookie = 'username=' + encodeURIComponent(uname) + ';path=/;max-age=3600';
document.cookie = 'role=admin;path=/;max-age=3600';
document.cookie = 'last_login=' + encodeURIComponent(new Date().toISOString()) + ';path=/;max-age=3600';
function getCookie(name) {
    const cookies = document.cookie.split(';');
    for (let cookie of cookies) {
        const [key, value] = cookie.split('=');
        if (key.trim() === name) {
            return decodeURIComponent(value);
        }
    }
    return null;
}

window.onload = function() {
    const username = getCookie('username');
    const role = getCookie('role');
    const lastLogin = getCookie('last_login');

    if (username) {
        document.body.innerHTML += '<p>欢迎回来，' + username + '！</p>';
        document.body.innerHTML += '<p>您的角色是：' + role + '</p>';
        document.body.innerHTML += '<p>上次登录时间：' + new Date(lastLogin).toLocaleString() + '</p>';
    } else {
        document.body.innerHTML += '<p>您尚未登录，请<a href="login.html">登录</a>。</p>';
    }
};